import request from '@/api/request';

// 频道新闻推荐_V1.1
export function getArticleListApi(params) {
  return request({
    method: "GET",
    params,
    url: "/app/v1_1/articles",
  })
}

// 获取新闻文章详情
export function getArticleDetailApi(articleId) {
  return request({
    method: "GET",
    url: `/app/v1_0/articles/${articleId}`
  })
}

// 收藏文章
export function addCollect(articleId) {
  return request({
    method: "POST",
    url: "/app/v1_0/article/collections",
    data: {
      "target": articleId
    }
  })
}

// 取消收藏文章
export function cancelCollect(articleId) {
  return request({
    method: "DELETE",
    url: `/app/v1_0/article/collections/${articleId}`
  })
}

// 点赞
export function addLike(articleId) {
  return request({
    method: "POST",
    url: "/app/v1_0/article/likings",
    data: {
      "target": articleId
    }
  })
}

// 取消收藏文章
export function cancelLike(articleId) {
  return request({
    method: "DELETE",
    url: `/app/v1_0/article/likings/${articleId}`
  })
}

// 文章评论
export function getCommentList(type,source,offset,limit) {
  return request({
    method: "GET",
    url: `/app/v1_0/comments`,
    params: {
      type,
      source,
      offset,
      limit	
    }
  })
}

// 对评论或评论回复点赞
export function addCommentLike(commentId) {
  return request({
    method: "POST",
    url: "/app/v1_0/comment/likings",
    data: {
      target: commentId
    }
  })
}

//取消对评论或评论回复点赞
export function deleteCommentLike(commentId) {
  return request({
    method: "DELETE",
    url: `/app/v1_0/comment/likings/${commentId}`,
  })
}

// 添加评论或评论回复
export function postComment(commentId,content,art_id) {
  return request({
    method: "POST",
    url: '/app/v1_0/comments',
    data: {
      target: commentId,
      content: content,
      art_id: art_id
    }
  })
}